﻿@page "/Admin/Emails"
@attribute [Authorize]
@attribute [TabItemOption(Text ="邮件发送",Icon ="fa fa-th")]
@inherits BasePage

<Card>
    <CardBody>
        <ValidateForm Model="@_model" OnInvalidSubmit="@OnInvalidSubmit" OnValidSubmit="@OnValidSubmit">
            <div class="row g-3">
                <div class="col-12">
                    <BootstrapInput @bind-Value="@_model.Recipient" />
                </div>
                <div class="col-12">
                    <BootstrapInput @bind-Value="@_model.Title" />
                </div>
                <div class="col-12">
                    <Switch @bind-Value="@_model.IsHtml" OnText="HTML" OffText="文本"></Switch>
				</div>
                <div class="col-12">
                    @if(_model.IsHtml)
                    {
                       <Markdown @bind-Value="@_model.Content"/>
                    }
                    else
                    {
                       <Textarea @bind-Value="@_model.Content" />
                    }
                </div>
                <div class="col-12">
                    <Button ButtonType="ButtonType.Submit" Icon="fa fa-fw fa-save" Text="发送" IsAsync="true" />
                </div>
            </div>
        </ValidateForm>
    </CardBody>
</Card>

@code{
    private EmailInput _model = new();

    private async Task OnInvalidSubmit(EditContext context)
    {
        await Toast.Warning("验证表单",$"验证未通过，请重新填写，4 秒后自动关闭");
    }

    private async Task OnValidSubmit(EditContext context)
    {
        await Toast.Success("提交表单",$"功能未实现，4 秒后自动关闭");
    }
}

